// 分类模块
import { topCategory } from "@/api/constants"
import { findAllCategory } from "@/api/category"
export default {
    namespaced: true,
    state() {
        return {
            // 分类信息
            categoryList: topCategory.map(item => ({ name: item }))
        }
    },
    mutations: {
        // 修改分类数据
        setCategoryList(state, payload) {
            state.categoryList = payload
        }
    },
    actions: {
        // 获取分类数据
        async getCategoryList({ commit }) {
            const data = await findAllCategory()
            commit("setCategoryList", data.result)
        }
    }
}